Ext.define('HIT.view.SetCompanyPanel', {
    extend: 'Ext.form.Panel',
    alias: 'widget.setcompanypanel',

    height: 660,
    width: 816,
    preventHeader: true,
    title: Share.T('公司设置'),
    setDisable: function (){
	  	Ext.getCmp('company_basic_info').setDisabled(true);
	    Ext.getCmp('company_other_info').setDisabled(true);
	    Ext.getCmp('one_manager').setDisabled(true);
	    Ext.getCmp('company_setting').setDisabled(true);
    },
    initComponent: function() {
        var me = this;
        //var companystore = Ext.create('HIT.store.Company',{});  
        //companystore.load();
        Ext.applyIf(me, {
            dockedItems: [
                {
                    xtype: 'treepanel',
                    id : 'companytree',
                    dock: 'left',
                    margin: '0 0 0 50',
                    width: 200,
                    title: Share.T('公司列表'),
                    store: 'Company',
                    closable: false,
                    collapsed: false,
                    collapsible: false,
                    rootVisible: true,
                    //useArrows: true,
                    viewConfig: {
                        //itemSelector: 'div'
                    }
                }
            ],
            items: [
                {
                    xtype: 'container',
                    height: 600,
                    padding: 20,
                    width: 547,
                    items: [
                        {
                            xtype: 'fieldset',
                            id:'company_basic_info',
                            height: 245,
                            width: 517,
                            title: Share.T('基本信息'),
                            items: [
                                {
                                    xtype: 'hiddenfield',
                                    id: 'companyId',
                                    value: -1
                                },    
                                {
                                    xtype: 'hiddenfield',
                                    id: 'currentSelectedId',
                                    value: -1
                                },
                                {
                                    xtype: 'hiddenfield',
                                    id: 'currentSelectedText',
                                    value: -1
                                },
                                {
                                    xtype: 'combobox',
                                    anchor: '100%',
                                    fieldLabel: Share.T('所属公司'),
        			                id: 'parentcompany',   
        			                editable: false,                                  
        			                store:new Ext.data.Store({
                    					proxy: { 
                        	                type: 'ajax', 
                        	                url : ctx + '/getParentCompanyList',
                        	                params:{      	                	
                        	                },
                        	                reader: { 
                        	                    type: 'json', 
                        	                    totalProperty: '', 
                        	                    root: '' 
                        	                } 
                        	        }, 
                        	        fields:['COMPANY_NAME','COMPANY_HID'], 
                        	        autoLoad:true 
	            			       	}),
	            			        valueField   : 'COMPANY_HID',
	                                displayField : 'COMPANY_NAME'
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'companycode',
                                    anchor: '100%',
                                    fieldLabel: Share.T('公司代码'),
                                    maxLength:20,
                                    allowBlank:false,
                                    blankText:Share.T('公司代码不能为空'),
                                    msgTarget  : 'side'
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'companyname',
                                    anchor: '100%',
                                    fieldLabel: Share.T('公司名称'),
                                    maxLength:50,
                                    allowBlank:false,
                                    blankText:Share.T('公司名称不能为空'),
                                    msgTarget  : 'side'
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'companyaddress',
                                    maxLength:50,
                                    anchor: '100%',
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('公司地址')
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'companycity',
                                    anchor: '100%',
                                    maxLength:50,
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('城市')
                                },{
                                	xtype:'panel',
                                	anchor: '100%',
                                	border:false,
                                	layout:{
                                		type:'absolute'
                                	},
                                	items:[{
                                        xtype: 'textfield',
                                        id : 'companypostcode',
                                        x:0,
                                        maxLength:50,
                                        width:200,
                                        msgTarget  : 'side',
                                        fieldLabel: Share.T('邮政编码')
                                    },
                                    {
                                        xtype: 'combobox',
                                        id : 'cpn_id',
                                        x:290,
                                        width:205,
                                        fieldLabel: Share.T('默认快递公司'),
            			                editable: false,
            			                valueField : 'value',
            							displayField : 'text',
            							allowBlank:false,
            							blankText:Share.T('必须选择一家快递公司'),
            			                store:new Ext.data.Store({
                        					proxy: { 
                            	                type: 'ajax', 
                            	                url : ctx + '/getExpressType',
                            	                params:{      	                	
                            	                },
                            	                reader: { 
                            	                    type: 'json', 
                            	                    totalProperty: '', 
                            	                    root: '' 
                            	                } 
	                            	        }, 
	                            	        fields : [ 'text', 'value' ],
	                            	        autoLoad:true 
            			                }),
                                        msgTarget  : 'side'
                                    },
                                    {
                                        xtype: 'textfield',
                                        id : 'company_status',
                                        value:'0',
                                        hidden:true
                                    }]
                                }
                            ]
                        },
                        {
                            xtype: 'fieldset',
                            id:'company_other_info',
                            height: 220,
                            width: 517,
                            title: Share.T('其他信息'),
                            items: [
                                {
                                    xtype: 'textfield',
                                    id : 'companyorgcode',
                                    maxLength:50,
                                    anchor: '100%',
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('组织机构代码')
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'accountmanager',
                                    anchor: '100%',
                                    maxLength:50,
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('会计主管')
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'operator',
                                    anchor: '100%',
                                    maxLength:50,
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('制单')
                                },
                                {
                                    xtype: 'textfield',
                                    id : 'checker',
                                    anchor: '100%',
                                    maxLength:50,
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('复核')
                                },{
                                    xtype: 'textareafield',
                                    id : 'companyrule',
                                    maxLength:500,
                                    height: 65,
                                    anchor: '100%',
                                    msgTarget  : 'side',
                                    fieldLabel: Share.T('发票存放位置')
                                },
                            ]
                        },
                        {
                        	//红废票审核权限设置
                        	xtype: 'fieldset',
                            height: 500,
                            id: 'one_manager',
                            width: 517,
                            layout: {
                                type: 'absolute'
                            },
                            title: Share.T('红废票审核权限设置'),
                            items: [{
                            	xtype:'displayfield',
                            	fieldLabel:Share.T('一级审核者'),
                            	labelWidth:200,
                            	x:0,
                            	y:12
                            },{
                            	xtype: 'itemselector',
                            	anchor: '100%',
                            	imagePath: ctx+'/resources/extjs/ux/images/',
                                x: 0,
                                y: 35,
                                height: 180,
                                id: 'first-level-checker',
                                name:'first-level-checker',
                                autoScroll:true,
                                width: 550,
                                store:new Ext.data.Store({
                                	proxy: { 
        								type: 'ajax', 
        								url : ctx + '/getUserList',
        								reader: { 
        									type: 'json', 
        									totalProperty: '', 
        									root: 'data' 
        								} 
        							},
        							fields:['text','value'], 
        							autoLoad:false ,
        							sortInfo: {
        								field: 'value',
        								direction: 'ASC'
        							}
                                }),
        						valueField : 'value',
        						displayField : 'text',
        						allowBlank: false,                
        	                    msgTarget: 'left',
        	                    fromTitle: Share.T('用户'),
        	                    toTitle: Share.T('管理者' )    
                            },{
                            	xtype:'displayfield',
                            	fieldLabel:Share.T('二级审核者'),
                            	labelWidth:200,
                            	x:0,
                            	y:255
                            },{
                            	xtype: 'itemselector',
                            	anchor: '100%',
                            	imagePath: ctx+'/resources/extjs/ux/images/',
                                x: 0,
                                y: 280,
                                height: 180,
                                id: 'second-level-checker',
                                name:'second-level-checker',
                                autoScroll:true,
                                width: 550,
                                store:new Ext.data.Store({
                                	proxy: { 
        								type: 'ajax', 
        								url : ctx + '/getUserList',
        								reader: { 
        									type: 'json', 
        									totalProperty: '', 
        									root: 'data' 
        								} 
        							},
        							fields:['text','value'], 
        							autoLoad:false ,
        							sortInfo: {
        								field: 'value',
        								direction: 'ASC'
        							}
                                }),
                                valueField : 'value',
                                displayField : 'text',
        						allowBlank: false,                
        						msgTarget: 'left',
        						fromTitle: Share.T('用户'),
        						toTitle: Share.T('管理者' )    
                            
                            }
                            ]
                        	
                        },

                        {
                            xtype: 'fieldset',
                            id:'company_setting',
                            height: 70,
                            padding: '10 0 0 10',
                            width: 517,
                            title: '',
                            layout: {
                                type: 'absolute'
                            },
                            items: [
                                {
                                    xtype: 'checkboxfield',
                                    id : 'applyExpress',
                                    x:5,
                                    y:5,
                                    width:250,
                                    fieldLabel: Share.T('是否启用快递100'),
                                    boxLabel: ''
                                },
                                {
                                    xtype: 'checkboxfield',
                                    id : 'archiveInvoice',
                                    x:260,
                                    y:5,
                                    labelWidth:160,
                                    fieldLabel: Share.T('是否启用发票归档功能'),
                                    boxLabel: ''
                                },
                                {
                                    xtype: 'checkboxfield',
                                    id : 'hasledger',
                                    x:5,
                                    y:35,
                                    width:250,
                                    fieldLabel: Share.T('是否启用该公司'),
                                    boxLabel: ''
                                },
                            ]
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
        me.setDisable();
    }

});